<template>
  <div>
    <activity_table :data_setting="data_setting"
                    :list="list"
                    @handleGetActivityInfo="handleGetActivityInfo"
    />
    <el-pagination
        :current-page="currentPage"
        :page-size="currentPageSize"
        :page-sizes="[10, 50, 100, 500, 1000, 99999]"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleGetBySizeActivity"
        @current-change="handleGetByNumActivity"
    />
  </div>
</template>
<script>

import Activity_table from "@/components/activity_table";

export default {
  components: { Activity_table },
  data () {
    return {
      data_setting: [
        { target: "activityName" },
        { target: "activityType" },
        { target: "communityName" },
        { target: "activityRecruitPeople" },
        { target: "activityRecruitedPeople" },
        { target: "activityCreatedate" },

      ],
      list: [],
      currentPage: 1,
      currentPageSize: 10,
      total: 0,
      keyword: "",
      dataRange: null,
      articleContentshow: false,
      sheet_list: [],
      signShow: false,
      signImg: "",
      searchTime: null,
      auditShow: false,
      auditRes: null,
      auditReason: null,
      refuseReason: false,
      articleShow: false,
      tmpActivityId: "",
    };
  },
  mounted () {
    this.handleGetByNumActivity(1);
  },
  methods: {
    // 格式化成为表格所需要的数据
    async handleGetBySizeActivity (size) {
      const pageNum = this.currentPage;
      let pageSize = this.currentPageSize;
      pageSize = size;
      const res = await this.$http.activityAll({
        pageNum,
        pageSize,
      });
      if (res.code !== 0) return null;
      this.list = res.data.list;
      this.total = res.data.totalCount;
    },

    // 分页查询全部活动
    async handleGetByNumActivity (num) {
      this.currentPage = num;
      await this.handleGetActivity();
    },
    async handleGetActivityInfo (params) {
      this.$emit("handleGetActivityInfo", params);
    },
    // 分页查询已完成的活动
    async handleGetActivity () {
      const res = await this.$http.activity_allStatus({
        pageNum: this.currentPage,
        pageSize: this.currentPageSize,
        status: 2,
      });
      if (res.code !== 0) return null;
      this.list = res.data.list;
      this.total = res.data.totalCount;
    },
  },
};
</script>
